package miiteen.customsportal.Api;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import miiteen.core.result.ResultMessage;
import miiteen.core.result.ResultMessageTool;
import miiteen.customsportal.basic.beans.BasicWindow;
import miiteen.customsportal.basic.service.BasicWindowService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 飘窗管理
 */
@Api(tags = "飘窗管理")
@RestController
@RequestMapping("/Api/basicWindowApi")
@CrossOrigin
public class BasicWindowApiController {
    @Autowired
    private BasicWindowService basicWindowService;
    //按当前时间查询所有飘窗
    @ApiOperation("按当前时间查询所有飘窗")
    @RequestMapping(value = "/findAll", method = RequestMethod.GET)
    public ResultMessage<Object> findAll(){
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Map<String,Object> map=new HashMap<>();
        map.put("allTime",formatter.format(new Date()));
        List<BasicWindow> listByMap = basicWindowService.findListByMap(map);
        if(listByMap!=null&&listByMap.size()>0){
            return ResultMessageTool.Success("查询成功", listByMap);
        }else{
            return ResultMessageTool.Error("查询失败");
        }
    }
}
